﻿//**************************************************************************//
// Copyright (C) Abdul Rasheed. All rights Reserved.                        //
// rasheedat.blogspot.com                                                   //
//**************************************************************************//

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PPHR.Common;
using PPHR.DataLogic;
namespace PPHR
{
    /// <summary>
    /// This UI used to store and update personal detail.
    /// </summary>
    public partial class PersonalDetail : Form
    {
        #region GlobalVariables
        int addressAction = -1;
        int otherIDsAction = -1;
        CommonDataLogic comDataLogic = new CommonDataLogic();
        #endregion GlobalVariables

        #region Constructor
        public PersonalDetail()
        {
            InitializeComponent();
        }
        #endregion Constructor

        #region Events
        /// <summary>
        /// On form load initialize controls and set the default values.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PersonalDetail_Load(object sender, EventArgs e)
        {
            try
            {
                LoadDefaultValue();
                SetValue();
                EnableAddressTab(false);
                EnableOtherIDsTab(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// when home menu clicked the hide this form and show the home page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemHome_Click(object sender, EventArgs e)
        {
            try
            {
                this.Hide();
                PPHR phr = new PPHR();
                phr.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// When Update menu clic save the details into data base. 
        /// Finally close the form and show the main form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemUpdate_Click(object sender, EventArgs e)
        {
            PersonalDetailLogic personalDataLogic = new PersonalDetailLogic();
            // Set Values 
            PersonalData PID = new PersonalData();
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                if (ValidateForm())
                {
                    // PersonalData
                    PID.PatientID = txtPatientID.Text;
                    PID.Name = txtName.Text;
                    PID.DOB = txtDOB.Value;
                    PID.Gender = ((System.Data.DataRowView)(cboGender.SelectedItem)).Row.ItemArray[0].ToString(); //cboGender.SelectedValue.ToString();
                    PID.MartialStatus = ((System.Data.DataRowView)(cboMartialStatus.SelectedItem)).Row.ItemArray[0].ToString(); //cboMartialStatus.SelectedValue.ToString();
                    PID.SSNumber = txtSSN.Text;
                    PID.DrivingLicenseNumber = txtDrivingLicense.Text;
                    PID.Nationality = ((System.Data.DataRowView)(cboNationality.SelectedItem)).Row.ItemArray[0].ToString();  //cboNationality.SelectedValue.ToString();
                    PID.AlergicTo = txtAlergic.Text;
                    PID.BloodGroup = txtBloodGroup.Text;
                    PID.MotherName = txtMothersName.Text;
                    PID.AliasName = txtAlias.Text;
                    PID.PrimaryLanguage = txtPrimaryLanguage.Text;

                    DataTable dtAddress = (DataTable)dgAddress.DataSource;
                    for (int row = 0; row < dtAddress.Rows.Count; row++)
                    {
                        Address address = new Address();
                        address.AddressType = dtAddress.Rows[row][1].ToString();
                        address.Street1 = dtAddress.Rows[row][3].ToString();
                        address.Street2 = dtAddress.Rows[row][4].ToString();
                        address.City = dtAddress.Rows[row][5].ToString();
                        address.State = dtAddress.Rows[row][6].ToString();
                        address.Zip = dtAddress.Rows[row][7].ToString();
                        address.Country = dtAddress.Rows[row][8].ToString();
                        address.Fax = dtAddress.Rows[row][9].ToString();
                        address.Phone = dtAddress.Rows[row][10].ToString();
                        PID.Addresses.Add(address);
                    }

                    DataTable dtOterIds = (DataTable)dgOtherIDs.DataSource;
                    for (int row = 0; row < dtOterIds.Rows.Count; row++)
                    {
                        IDs idS = new IDs();
                        idS.Hospital = dtOterIds.Rows[row][0].ToString();
                        idS.HospitalID = dtOterIds.Rows[row][1].ToString();
                        PID.OtherIDs.Add(idS);
                    }
                    personalDataLogic.UpdateDetail(PID);
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("Details Updated Successfully.", Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    this.Close();
                }
                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }

        }

        /// <summary>
        /// Close the form and show the main form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemClose_Click(object sender, EventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// If there is no records in grid then disable edit and delete menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenuAddr_Popup(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = (DataTable)dgAddress.DataSource;
                if (dt.Rows.Count <= 0)
                {
                    contextMenuAddr.MenuItems[1].Enabled = false;
                    contextMenuAddr.MenuItems[2].Enabled = false;
                }
                else
                {
                    contextMenuAddr.MenuItems[1].Enabled = true;
                    contextMenuAddr.MenuItems[2].Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// If there is no records in grid then disable edit and delete menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenuIDs_Popup(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = (DataTable)dgOtherIDs.DataSource;
                if (dt.Rows.Count <= 0)
                {
                    contextMenuIDs.MenuItems[1].Enabled = false;
                    contextMenuIDs.MenuItems[2].Enabled = false;
                }
                else
                {
                    contextMenuIDs.MenuItems[1].Enabled = true;
                    contextMenuIDs.MenuItems[2].Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        #region Address Tab
        /// <summary>
        /// Based on action Add a new item or edit the selected item or delete the selected item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddressOK_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dtAddress = (DataTable)dgAddress.DataSource;
                if (ValidateAddressTab())
                {
                    if (addressAction == Constants.ACTION_NEW)
                    {
                        DataRow dr = dtAddress.NewRow();
                        dr[0] = txtPatientID.Text;
                        dr[1] = ((System.Data.DataRowView)(cboAddressType.SelectedItem)).Row.ItemArray[0].ToString(); //cboAddressType.Text;
                        dr[2] = ((System.Data.DataRowView)(cboAddressType.SelectedItem)).Row.ItemArray[1].ToString();
                        dr[3] = txtStreet1.Text;
                        dr[4] = txtStreet2.Text;
                        dr[5] = txtCity.Text;
                        dr[6] = txtState.Text;
                        dr[7] = txtZip.Text;
                        dr[8] = txtCountry.Text;
                        dr[9] = txtFax.Text;
                        dr[10] = txtPhone.Text;
                        dtAddress.Rows.Add(dr);
                        dgAddress.DataSource = dtAddress;
                    }
                    if (addressAction == Constants.ACTION_EDIT)
                    {
                        int index = dgAddress.CurrentRowIndex;
                        DataRow dr = dtAddress.Rows[index];
                        dr[0] = txtPatientID.Text;
                        dr[1] = ((System.Data.DataRowView)(cboAddressType.SelectedItem)).Row.ItemArray[0].ToString(); //cboAddressType.Text;
                        dr[2] = ((System.Data.DataRowView)(cboAddressType.SelectedItem)).Row.ItemArray[1].ToString();
                        dr[3] = txtStreet1.Text;
                        dr[4] = txtStreet2.Text;
                        dr[5] = txtCity.Text;
                        dr[6] = txtState.Text;
                        dr[7] = txtZip.Text;
                        dr[8] = txtCountry.Text;
                        dr[9] = txtFax.Text;
                        dr[10] = txtPhone.Text;
                        dgAddress.DataSource = dtAddress;
                    }

                    if (addressAction == Constants.ACTION_DELETE)
                    {
                        int index = dgAddress.CurrentRowIndex;
                        dtAddress.Rows.RemoveAt(index);
                        dgAddress.DataSource = dtAddress;
                    }
                    ClearAddressTab();
                    EnableAddressTab(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// On address context menu new option, clear the controls and make it ready to add new record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemAddresNew_Click(object sender, EventArgs e)
        {
            try
            {
                addressAction = Constants.ACTION_NEW;
                ClearAddressTab();
                EnableAddressTab(true);
                btnAddressOK.Text = "Add";
                cboAddressType.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// On address context menu edit option, load the selected row values in appropriate controls
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemAddresEdit_Click(object sender, EventArgs e)
        {
            try
            {
                addressAction = Constants.ACTION_EDIT;
                int index = dgAddress.CurrentRowIndex;
                DataTable dtAddress = (DataTable)dgAddress.DataSource;
                DataRow dr = dtAddress.Rows[index];
                LoadAddressTabValue(dr);
                btnAddressOK.Text = "Update";
                EnableAddressTab(true);
                cboAddressType.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// On address context menu delete option, load the selected row values in appropriate controls
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemAddresDelete_Click(object sender, EventArgs e)
        {
            try
            {
                addressAction = Constants.ACTION_DELETE;
                int index = dgAddress.CurrentRowIndex;
                DataTable dtAddress = (DataTable)dgAddress.DataSource;
                DataRow dr = dtAddress.Rows[index];
                LoadAddressTabValue(dr);
                EnableAddressTab(false);
                btnAddressOK.Enabled = true;
                btnAddressOK.Text = "Delete";
                btnAddressOK.Focus();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }
        #endregion Address Tab

        #region Other IDs tab
        /// <summary>
        /// Based on action Add a new item or edit the selected item or delete the selected item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOtherIDsOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateOtherIdsTab())
                {
                    DataTable dtOtherIDs = (DataTable)dgOtherIDs.DataSource;
                    if (otherIDsAction == Constants.ACTION_NEW)
                    {

                        DataRow dr = dtOtherIDs.NewRow();
                        dr[0] = txtHospitalName.Text;
                        dr[1] = txtHospitalID.Text;
                        dtOtherIDs.Rows.Add(dr);
                    }
                    if (otherIDsAction == Constants.ACTION_EDIT)
                    {
                        int index = dgOtherIDs.CurrentRowIndex;
                        DataRow dr = dtOtherIDs.Rows[index];
                        dr[0] = txtHospitalName.Text;
                        dr[1] = txtHospitalID.Text;
                    }
                    if (otherIDsAction == Constants.ACTION_DELETE)
                    {
                        int index = dgOtherIDs.CurrentRowIndex;
                        dtOtherIDs.Rows.RemoveAt(index);
                    }
                    dgOtherIDs.DataSource = dtOtherIDs;
                    ClearOtherIDsTab();
                    EnableOtherIDsTab(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// On Otjer Ids context menu new option, clear the controls and make it ready to add a new record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemIDsNew_Click(object sender, EventArgs e)
        {
            try
            {
                otherIDsAction = Constants.ACTION_NEW;
                ClearOtherIDsTab();
                EnableOtherIDsTab(true);
                btnOtherIDsOK.Text = "Add";
                txtHospitalName.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// On Other ids context menu edit option, load the selected row values in appropriate controls
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemIDsEdit_Click(object sender, EventArgs e)
        {
            try
            {
                otherIDsAction = Constants.ACTION_EDIT;
                int index = dgOtherIDs.CurrentRowIndex; //lvAddress.SelectedIndices.IndexOf(0);
                DataTable dtIDs = (DataTable)dgOtherIDs.DataSource;
                DataRow dr = dtIDs.Rows[index];

                LoadOtherIDsTabValue(dr);
                btnOtherIDsOK.Text = "Update";
                EnableOtherIDsTab(true);
                txtHospitalName.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// On other ids context menu delete option, load the selected row values in appropriate controls
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemIDsDelete_Click(object sender, EventArgs e)
        {
            try
            {
                otherIDsAction = Constants.ACTION_DELETE;
                int index = dgOtherIDs.CurrentRowIndex; //lvAddress.SelectedIndices.IndexOf(0);
                DataTable dtIDs = (DataTable)dgOtherIDs.DataSource;
                DataRow dr = dtIDs.Rows[index];
                LoadOtherIDsTabValue(dr);
                EnableOtherIDsTab(false);
                btnOtherIDsOK.Text = "Delete";
                btnOtherIDsOK.Enabled = true;
                btnOtherIDsOK.Focus();
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }
        #endregion Other IDs tab

        #endregion Events

        #region Other Methods

        /// <summary>
        /// Initialize all combo box and other controls with default values
        /// </summary>
        private void LoadDefaultValue()
        {
            //Load Combo Box
            DataTable dtGender = comDataLogic.GetMasterTable("GENDER");
            DataTable dtMartialStatus = comDataLogic.GetMasterTable("MARTIAL");
            DataTable dtNationality = comDataLogic.GetMasterTable("NATION");
            DataTable dtAddressType = comDataLogic.GetMasterTable("ADDRTYPE");

            cboGender.DataSource = dtGender;
            cboGender.ValueMember = dtGender.Columns[0].ColumnName;
            cboGender.DisplayMember = dtGender.Columns[1].ColumnName;
            cboGender.SelectedIndex = 0;

            cboMartialStatus.DataSource = dtMartialStatus;
            cboMartialStatus.ValueMember = dtGender.Columns[0].ColumnName;
            cboMartialStatus.DisplayMember = dtMartialStatus.Columns[1].ColumnName;
            cboMartialStatus.SelectedIndex = 0;

            cboNationality.DataSource = dtNationality;
            cboNationality.ValueMember = dtGender.Columns[0].ColumnName;
            cboNationality.DisplayMember = dtNationality.Columns[1].ColumnName;
            cboNationality.SelectedIndex = 0;

            cboAddressType.DataSource = dtAddressType;
            cboAddressType.ValueMember = dtGender.Columns[0].ColumnName;
            cboAddressType.DisplayMember = dtAddressType.Columns[1].ColumnName;
            cboAddressType.SelectedIndex = 0;
        }

        /// <summary>
        /// Set the values in control if already exist
        /// </summary>
        private void SetValue()
        {
            PersonalDetailLogic personalDataLogic = new PersonalDetailLogic();
            //Load other controls
            PersonalData PID = personalDataLogic.GetPersonalData();
            if (PID != null)
            {
                txtPatientID.Text = PID.PatientID;
                txtName.Text = PID.Name;
                txtDOB.Value = DateTime.Parse(PID.DOB.ToString("dd-MMM-yyyy"));
                cboGender.Text = comDataLogic.GetDescriptionForCode("GENDER", PID.Gender);
                cboMartialStatus.Text = comDataLogic.GetDescriptionForCode("MARTIAL", PID.MartialStatus);
                txtSSN.Text = PID.SSNumber;
                txtDrivingLicense.Text = PID.DrivingLicenseNumber;
                cboNationality.Text = comDataLogic.GetDescriptionForCode("NATION", PID.Nationality);
                txtAlergic.Text = PID.AlergicTo;
                txtBloodGroup.Text = PID.BloodGroup;
                txtMothersName.Text = PID.MotherName;
                txtAlias.Text = PID.AliasName;
                txtPrimaryLanguage.Text = PID.PrimaryLanguage;
            }
            // Load Grid

            DataTable dtAddress = personalDataLogic.GetPersonAddress();
            dgAddress.DataSource = dtAddress;

            DataTable dtOtherIDs = personalDataLogic.GetPersonOtherIDs();
            dgOtherIDs.DataSource = dtOtherIDs;
        }

        /// <summary>
        /// Before submitting the data into database validate for any error. 
        /// </summary>
        /// <returns>If all the contiditions are passed then return true.</returns>
        private bool ValidateForm()
        {
            // Personal Detail Tab
            if (txtPatientID.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter Valid Patient ID.", Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                txtPatientID.Focus();
                return false;
            }
            if (txtName.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter Valid Name.", Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                txtName.Focus();
                return false;
            }
            if (txtDOB.Value > DateTime.Now)
            {
                MessageBox.Show("Date of Birth can't be future date.", Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                txtDOB.Focus();
                return false;
            }
            if (cboGender.SelectedIndex.Equals(0))
            {
                MessageBox.Show("Please Choose a Gender from the list.", Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                cboGender.Focus();
                return false;
            }
            // Address Tab
            DataTable dt = (DataTable)dgAddress.DataSource;

            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("Please enter atleast one address.", Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                tabControl.SelectedIndex = 1;
                return false;
            }
            return true;
        }

        #region Address Tab
        /// <summary>
        /// Enable or disable the controls in address tab
        /// </summary>
        /// <param name="value">true or false</param>
        private void EnableAddressTab(bool value)
        {
            cboAddressType.Enabled = value;
            txtStreet1.Enabled = value;
            txtStreet2.Enabled = value;
            txtCity.Enabled = value;
            txtState.Enabled = value;
            txtZip.Enabled = value;
            txtCountry.Enabled = value;
            txtFax.Enabled = value;
            txtPhone.Enabled = value;
            btnAddressOK.Enabled = value;
        }

        /// <summary>
        /// Clear values in address tab controls
        /// </summary>
        private void ClearAddressTab()
        {
            cboAddressType.SelectedIndex = 0;
            txtStreet1.Text = string.Empty;
            txtStreet2.Text = string.Empty;
            txtCity.Text = string.Empty;
            txtState.Text = string.Empty;
            txtZip.Text = string.Empty;
            txtCountry.Text = string.Empty;
            txtFax.Text = string.Empty;
            txtPhone.Text = string.Empty;
        }

        /// <summary>
        /// Load values from data table to controls
        /// </summary>
        /// <param name="dr">selected data table row</param>
        private void LoadAddressTabValue(DataRow dr)
        {
            cboAddressType.Text = dr[2].ToString();
            txtStreet1.Text = dr[3].ToString();
            txtStreet2.Text = dr[4].ToString();
            txtCity.Text = dr[5].ToString();
            txtState.Text = dr[6].ToString();
            txtZip.Text = dr[7].ToString();
            txtCountry.Text = dr[8].ToString();
            txtFax.Text = dr[9].ToString();
            txtPhone.Text = dr[10].ToString();
        }

        /// <summary>
        /// Validate address tab control values before adding in Data Grid 
        /// </summary>
        /// <returns>true or false</returns>
        private bool ValidateAddressTab()
        {
            if (cboAddressType.SelectedIndex.Equals(0))
            {
                MessageBox.Show("Please Choose an valid address Type.", Constants.MessageBoxCaption);
                tabAddress.Show();
                cboAddressType.Focus();
                return false;
            }
            if (txtStreet1.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter Valid Street Name.", Constants.MessageBoxCaption);
                txtStreet1.Focus();
                return false;
            }
            if (txtZip.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter Valid Zip code.", Constants.MessageBoxCaption);
                txtZip.Focus();
                return false;
            }
            return true;
        }
        #endregion Address Tab

        #region Other IDs Tab
        /// <summary>
        /// Enable or disable the controls in other ids tab
        /// </summary>
        /// <param name="value">true or false</param>
        private void EnableOtherIDsTab(bool value)
        {
            txtHospitalName.Enabled = value;
            txtHospitalID.Enabled = value;
            btnOtherIDsOK.Enabled = value;
        }

        /// <summary>
        /// Clear values from Other Ids tab controls
        /// </summary>
        private void ClearOtherIDsTab()
        {
            txtHospitalName.Text = string.Empty;
            txtHospitalID.Text = string.Empty;
        }

        /// <summary>
        /// Load values from data table to controls
        /// </summary>
        /// <param name="dr">selected data table row</param>
        private void LoadOtherIDsTabValue(DataRow dr)
        {
            txtHospitalName.Text = dr[0].ToString();
            txtHospitalID.Text = dr[1].ToString();
        }

        /// <summary>
        /// Validate address tab control values before adding to Data Grid 
        /// </summary>
        /// <returns>true or false</returns>
        private bool ValidateOtherIdsTab()
        {
            if (txtHospitalName.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter Valid Hospital/Clinic Name.", Constants.MessageBoxCaption);
                txtHospitalName.Focus();
                return false;
            }
            if (txtHospitalID.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter Valid Hospital ID.", Constants.MessageBoxCaption);
                txtHospitalID.Focus();
                return false;
            }
            return true;
        }
        #endregion Other IDs Tab


        #endregion Other Methods
    }
}